<?php
//TODO: Getting there, but it still sucks big... need to support multiple levels, not just two!
// NASTY NASTY NASTY CODE!!!!
class XmlSearcher {

	function GetElements( $oXmlElement, $sSearchString ) {

		$oSearchContainer = null;

		if ( strpos( $sSearchString, '>>' ) ) {
			$aElementNames = explode( '>>', $sSearchString );
			$oXmlElement->GetElements( $oSearchContainer, $aElementNames[0] );
			return XmlSearcher::GetElementsFromSearchContainer( $oSearchContainer, $aElementNames[1] );
		}

		$oXmlElement->GetElements( $oSearchContainer, $sSearchString );
		return $oSearchContainer;
		
	}
	
	function GetElementsFromSearchContainer( $oContainerToSearch, $sElementName ) {
		$oResultsContainer = null;
		$oContainerToSearch->RewindElementIterator();
		while( $oContainerToSearch->HasAnotherElement() ) {
			$oThisElementToSearch = $oContainerToSearch->GetNextElement();
			$oThisElementToSearch->GetElements( $oResultsContainer, $sElementName, false );
		}
		return $oResultsContainer;
	}
	
}
?>
